import java.util.Random;
import java.util.Scanner;


public class Guess_the_numbers {
    public static void main(String[] args) {
        final int I = 1;
        int i = I;
        Random r = new Random();
        int number = r.nextInt(100) + 1;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你猜测的数字");

        while(true) {
            int guessnumber = sc.nextInt();
            i--;
            if (guessnumber == number) {
                System.out.println("恭喜你猜对了,数字为" + number);
                break;
            } else if (guessnumber > number) {
                System.out.println("你猜大了,请再次猜测,还剩余机会" + i );
            }else {
                System.out.println("你猜小了,请再次猜测,还剩余机会" + i );
            }
            if(i == 0){
                System.out.println("很遗憾你输了,请重新开始游戏");
                break;
            }
        }

    }
}
